﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aij1.Model;
using System.Web;
using Aij1.Utils;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;

namespace Aij1.BLL
{
    public class UserData
    {
        public static S_Person GetCurrentUser(Session session)
        {
            int userId = CommOp.ToInt(HttpContext.Current.Session["UserId"]);
            if (userId > 0)
                return session.GetObjectByKey<S_Person>(userId);
            else return null;
        }

        public static S_Person GetUserInfo(Session session, string userName)
        {
            return session.FindObject<S_Person>(CriteriaOperator.Parse("SysName=?", userName));
        }

        public static void SetCurrentUser(S_Employee employee)
        {
            HttpContext.Current.Session["UserId"] = employee.Oid;
        }
    }
}
